import request from './request'

export const downloadFile = async (path) => {
  const paths = path.split('/')
  // 获取文件名字
  const name = paths[paths.length - 1]
  const result = await request.get(`/files/download/${name}`, {
    responseType: 'blob' // 设置响应类型为blob
  })
  // 处理头像的二进制信息并生成URL
  const url = URL.createObjectURL(result)
  return url
}
